﻿<%@ WebHandler Language="C#" Class="list" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.Script.Serialization;
using System.Web.SessionState;
using System.Web.Services;

public class list : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
    private StringBuilder sb = null;
    public DataSet ds = null;
    public DataTable dt = null;
    private string sqlwhere = "";
    public void ProcessRequest (HttpContext context) {
        string type = PageBase.ext_string(context.Request.Params["type"]);

        switch (type)
        {
            //查询预收单
            case "getlist_ysd":
                getinfo_list_ysd(context);
                break;
            //根据预收单查询款号
            case "getlist_kh":
                getinfo_list_kh(context);
                break;
            //获取图片信息
            case "getlist_pic":
                getinfo_list_pic(context);
                break;
            //获取尺码信息
            case "getcm":
                getinfo_cm(context);
                break;
            //获取装饰工艺信息
            case "getzsgy":
                getinfo_zsgy(context);
                break;
            //根据尺码id获取尺码信息
            case "getcmbysel":
                getinfo_cmbysel(context);
                break;
            //获取特体信息
            case "getothercm":
                getinfo_othercm(context);
                break;
            //根据工厂面料号获取面料编码
            case "getmlbm_bygcmlh":
                getinfo_getmlbm(context);
                break;
            //保存订单
            case "order_save":
                order_save(context);
                break;
            //获取订单列表
            case "getlist":
                getinfo_list(context);
                break;
            //获取订单审核列表
            case "getshlist":
                getinfo_shlist(context);
                break;
            //根据id获取信息
            case "getlist_byid":
                getlist_byid(context);
                break;
            //删除
            case "delete":
                delete(context);
                break;
            //复制订单
            case "copy":
                copy(context);
                break;
            //审核
            case "audit":
                audit(context);
                break;
            //驳回
            case "return_order":
                return_order(context);
                break;
            //获取操作流水记录
            case "getlist_ls":
                getinfo_list_ls(context);
                break;
            //获取订单配置信息，加急天数等
            case "getorder_set":
                getorder_set(context);
                break;
            default:
                //getinfo(context);
                break;
        }
    }
    //查询高定配置信息
    public void getorder_set(HttpContext context)
    {

        string sql = @"select id,shrq_add,jjts,jjfy from [t_set]";
        DataTable dt = DBHelper.ExecuteDataTable(sql);

        sb = new StringBuilder();
        string code = "0";
        string msg = "";

        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"shrq_add\":\"" + dt.Rows[i]["shrq_add"] + "\"");
            sb.Append(",\"jjts\":\"" + dt.Rows[i]["jjts"] + "\"");
            sb.Append(",\"jjfy\":\"" + dt.Rows[i]["jjfy"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //获取操作流水
    public void getinfo_list_ls(HttpContext context)
    {
        //页数1
        int page = PageBase.ext_int(context.Request.Params["page"]);
        //每页条数10
        int limit =PageBase.ext_int(context.Request.Params["limit"]);
        //排序字段
        string field =PageBase.ext_string(context.Request.Params["field"]);
        //排序方式
        string order = PageBase.ext_string(context.Request.Params["order"]);

        string djdocno = PageBase.ext_string(context.Request.Params["djdocno"]);
        string orderby = "cztime desc";
        string where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,docno,cz,czrname,cztime,remark
                        from t_order_mainlog where 1=1 and docno='"+djdocno+"'";

        if (!string.IsNullOrEmpty(order) && !string.IsNullOrEmpty(field))
        {
            orderby =field + " " + order;
        }
        DataTable dt =  DBHelper.Pagination2(where, limit, page, orderby, "");
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        int count = 0;
        if(dt.Rows.Count>0)
            count = PageBase.ext_int(dt.Rows[0]["TOTAL"].ToString());

        sb.Append("{\"code\":\"" + code + "\",\"count\":" + count + ",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"docno\":\"" + dt.Rows[i]["docno"].ToString() + "\"");
            sb.Append(",\"cz\":\"" + dt.Rows[i]["cz"] + "\"");
            sb.Append(",\"czrname\":\"" + dt.Rows[i]["czrname"] + "\"");
            sb.Append(",\"cztime\":\"" + dt.Rows[i]["cztime"] + "\"");
            sb.Append(",\"remark\":\"" + dt.Rows[i]["remark"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //复制订单
    public void copy(HttpContext context)
    {
        string getids = PageBase.ext_string(context.Request.Params["getids"]);
        string msg = "";
        bool flag;
        string sql_zt = @"exec [zdy_复制订单] '{0}'";
        sql_zt = string.Format(sql_zt, getids);
        DataTable dtzt=  DBHelper.ExecuteDataTable(sql_zt);
        if (dtzt.Rows[0]["remsg"].ToString() =="复制成功")
        {
            flag = true;
            msg = "复制成功";
        }
        else
        {
            flag = false;
            msg = "复制失败";

        }
        context.Response.Write("{\"flag\":\"" + flag + "\",\"remsg\":\"" + msg + "\"}");
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //驳回
    public void return_order(HttpContext context)
    {
        string getids = PageBase.ext_string(context.Request.Params["getids"]);
        string userid = PageBase.ext_string(context.Request.Params["userid"]);
        string username = PageBase.ext_string(context.Request.Params["usernames"]);
        string docno = PageBase.ext_string(context.Request.Params["docno"]);

        string return_remark = PageBase.ext_string(context.Request.Params["return_remark"]);
        string msg = "";
        bool flag;
        string sqldelete = "update t_order_main set status='-1',audit_remark='{0}' where id in ({1})";
        sqldelete = string.Format(sqldelete,return_remark, getids);
        int dtcount= DBHelper.ExecuteNonQuery(sqldelete);
        if (dtcount > 0)
        {
            flag = true;
            msg = "驳回成功";
            //string sql_zt = @"exec [zdy_更新操作步骤] '{0}','{1}','{2}'";
            //sql_zt = string.Format(sql_zt, docno, "驳回",userid);
            //DBHelper.ExecuteNonQuery(sql_zt);

            string sql_zt = @"insert into t_order_mainlog(docno,cz,czrid,czrname,cztime,remark) values('{0}','{1}','{2}','{3}','{4}','{5}')";
            sql_zt = string.Format(sql_zt,docno,"驳回",userid,username,DateTime.Now.ToString(),return_remark);
            DBHelper.ExecuteNonQuery(sql_zt);
        }
        else
        {
            flag = false;
            msg = "驳回失败";

        }
        context.Response.Write("{\"flag\":\"" + flag + "\",\"remsg\":\"" + msg + "\"}");
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //审核
    public void audit(HttpContext context)
    {
        string getids = PageBase.ext_string(context.Request.Params["getids"]);
        string userid = PageBase.ext_string(context.Request.Params["userid"]);
        string username = PageBase.ext_string(context.Request.Params["usernames"]);
        decimal? ylms = PageBase.ext_decimal(context.Request.Params["ylms"]);

        string msg = "";
        bool flag=false;

        string getmaininfo_sql = "select * from t_order_main where id in ({0})";
        getmaininfo_sql = string.Format(getmaininfo_sql, getids);
        DataTable dtmaininfo = DBHelper.ExecuteDataTable(getmaininfo_sql);

        for (int i = 0; i < dtmaininfo.Rows.Count; i++)
        {


            string csdocno = dtmaininfo.Rows[i]["docno"].ToString();

            string isscdh_sql = "exec [zdy_查询夏梦单号] '{0}'";
            isscdh_sql = string.Format(isscdh_sql, csdocno);
            DataTable isscdh_dt = DBHelper.ExecuteDataTable(isscdh_sql);
            string scdhmsg = isscdh_dt.Rows[0]["zt"].ToString();
            if (scdhmsg == "夏梦单号已存在")
            {
                flag = false;
                msg = "审核失败,单号已存在";

            }
            else
            {
                string ld_docno = dtmaininfo.Rows[i]["ld_docno"].ToString();
                string Customer_code = "1";
                string customer_name = dtmaininfo.Rows[i]["customer_name"].ToString();
                string customer_tel = dtmaininfo.Rows[i]["customer_tel"].ToString();
                string customer_address = dtmaininfo.Rows[i]["customer_address"].ToString();
                string store_name = dtmaininfo.Rows[i]["store_name"].ToString();
                string MeasureMaster_code = "lt_001";
                string MeasureMaster_name = "ld_name";
                string IsDirectSend_Customer = "Y";


                string sqlmain = @" exec [zdy_传入伯俊量定订单中间表主表] '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}' ";
                sqlmain = string.Format(sqlmain, csdocno, ld_docno, Customer_code, customer_name,
                    customer_tel, customer_address, store_name, MeasureMaster_code, MeasureMaster_name, IsDirectSend_Customer);
                DataTable maincount_dt = DBHelper.ExecuteDataTable(sqlmain);
                string remsgmain = maincount_dt.Rows[0]["zt"].ToString();

                if (remsgmain == "成功")
                {
                    string mid = maincount_dt.Rows[0]["remsg"].ToString();
                    string producnt_count = dtmaininfo.Rows[i]["product_count"].ToString();
                    string factory_mat = dtmaininfo.Rows[i]["factory_mat"].ToString();
                    string use_mat = dtmaininfo.Rows[i]["use_mat"].ToString();

                    string sqlmx = @"exec [zdy_传入伯俊量定订单中间表明细表] '{0}','{1}','{2}','{3}' ";
                    sqlmx = string.Format(sqlmx, mid, producnt_count, factory_mat, use_mat);
                    DataTable maincount_mx = DBHelper.ExecuteDataTable(sqlmx);
                    string remsgmx = maincount_mx.Rows[0]["zt"].ToString();
                    if (remsgmx == "成功")
                    {
                        string sqlproc = @"exec [zdy_执行伯俊量定存储过程] '{0}'";
                        sqlproc = string.Format(sqlproc, mid);
                        DataTable dt_proc = DBHelper.ExecuteDataTable(sqlproc);
                        string proc_msg = dt_proc.Rows[0]["zt"].ToString();

                        //写入日志
                        string insert_log = @"insert into t_interface_log(type, docno, ld_docno, post_json, posttime, postman, status, errmsg, createtime)
                                 values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')";
                        insert_log = string.Format(insert_log, "沙驰订单", csdocno, ld_docno, "", DateTime.Now, "沙驰", proc_msg, dt_proc.Rows[0]["remsg"].ToString(), DateTime.Now);
                        DBHelper.ExecuteNonQuery(insert_log);
                        if (proc_msg == "成功")
                        {
                            string sqldelete = @"update t_order_main set status='99',zhczrid='{0}',zhczrname='{1}',zhcztime='{2}',use_mat={3} where id in ({4});";
                            sqldelete = string.Format(sqldelete, userid,username,DateTime.Now.ToString(),ylms,getids);
                            int dtcount = DBHelper.ExecuteNonQuery(sqldelete);
                            if (dtcount > 0)
                            {
                                //string sql_zt = @"exec [zdy_更新操作步骤] '{0}','{1}','{2}'";
                                //sql_zt = string.Format(sql_zt, csdocno, "审核",userid);
                                //DBHelper.ExecuteNonQuery(sql_zt);
                                flag = true;
                                msg = "审核成功，伯俊处理成功";

                                string sql_zt = @"insert into t_order_mainlog(docno,cz,czrid,czrname,cztime,remark) values('{0}','{1}','{2}','{3}','{4}','{5}')";
                                sql_zt = string.Format(sql_zt,csdocno,"审核",userid,username,DateTime.Now.ToString(),"");
                                DBHelper.ExecuteNonQuery(sql_zt);


                            }
                            else
                            {
                                flag = false;
                                msg = "审核失败";
                            }
                        }
                        else
                        {
                            flag = false;
                            msg = "审核失败，伯俊处理失败，原因:" + dt_proc.Rows[0]["remsg"].ToString();
                        }
                    }
                    else
                    {
                        flag = false;
                        msg = "审核失败，传入中间表失败，请联系管理员";
                    }
                }
                else
                {
                    flag = false;
                    msg = "审核失败，传入中间表失败，请联系管理员";
                }
            }
        }
        context.Response.Write("{\"flag\":\"" + flag + "\",\"remsg\":\"" + msg + "\"}");
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //删除
    public void delete(HttpContext context)
    {
        string getids = PageBase.ext_string(context.Request.Params["getids"]);
        string userid = PageBase.ext_string(context.Request.Params["userid"]);
        string username = PageBase.ext_string(context.Request.Params["usernames"]);
        string lddocno = PageBase.ext_string(context.Request.Params["lddocno"]);
        string msg = "";
        bool flag;
        string sqldelete = "update t_order_main set isactive='N' where id in ({0})";
        sqldelete = string.Format(sqldelete, getids);
        int dtcount= DBHelper.ExecuteNonQuery(sqldelete);
        if (dtcount > 0)
        {
            flag = true;
            msg = "删除成功";

            string sql_zt = @"insert into t_order_mainlog(docno,cz,czrid,czrname,cztime,remark) values('{0}','{1}','{2}','{3}','{4}','{5}')";
            sql_zt = string.Format(sql_zt,lddocno,"删除",userid,username,DateTime.Now.ToString(),"");
            DBHelper.ExecuteNonQuery(sql_zt);
        }
        else
        {
            flag = false;
            msg = "删除失败";

        }
        context.Response.Write("{\"flag\":\"" + flag + "\",\"remsg\":\"" + msg + "\"}");
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //查询特体信息根据id
    public void getlist_byid(HttpContext context)
    {
        string editid = PageBase.ext_string(context.Request.Params["editid"]);
        //主体信息
        string sql = @"select a.id, a.docno, a.ld_docno, a.store_docno,a.store_id, a.store_name, a.customer_name, 
      a.customer_tel, a.customer_height, a.customer_weight,ltrim(rtrim(a.iszf)) iszf, a.customer_address,ltrim(rtrim(a.isjj)) isjj,a.jjts,a.jjfy,a.cxordx,a.product_xiaolei, a.product_value, 
      a.product_name, a.product_size, a.product_price, a.product_count, a.fabric_brand, a.fabric_code, 
      a.factory_mat, a.use_mat,CONVERT(VARCHAR(10),a.order_date,120) AS order_date,CONVERT(VARCHAR(10),a.delivery_date,120) AS delivery_date,a.lx_picid, a.lx_picurl, a.lx_piccode, 
      a.lx_picname, a.xk_picid, a.xk_picurl, a.xk_piccode, a.xk_picname, a.qmj_picid, a.qmj_picurl, 
      a.qmj_piccode, a.qmj_picname, a.xb_picid, a.xb_picurl, a.xb_piccode, a.xb_picname, a.hb_picid, 
      a.hb_picurl, a.hb_piccode, a.hb_picname, a.kd_picid, a.kd_picurl, a.kd_piccode, a.kd_picname, 
      a.lcp_picid, a.lcp_picurl, a.lcp_piccode, a.lcp_picname, 
      a.xhbw_picid, a.xhbw_picurl, a.xhbw_piccode, a.xhbw_picname, a.xhzt_picid, a.xhzt_picurl, 
      a.xhzt_piccode, a.xhzt_picname, a.xhys_picid, a.xhys_picurl, a.xhys_piccode, a.xhys_picname, a.xh_remark , a.gy_nkid,a.gy_mjid,a.gy_lzid,a.gy_xkid,
      a.remark, a.status, ltrim(rtrim(a.isactive)) as isactive, a.creater_id,a.createtime, a.reviser_id, a.revisiontime from t_order_main a 
	  where id={0} and a.isactive='Y'";
        sql = string.Format(sql,editid);
        DataTable dt = DBHelper.ExecuteDataTable(sql);

        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"docno\":\"" + dt.Rows[i]["docno"] + "\"");
            sb.Append(",\"ld_docno\":\"" + dt.Rows[i]["ld_docno"] + "\"");
            sb.Append(",\"store_docno\":\"" + dt.Rows[i]["store_docno"] + "\"");
            sb.Append(",\"store_id\":\"" + dt.Rows[i]["store_id"] + "\"");
            sb.Append(",\"store_name\":\"" + dt.Rows[i]["store_name"] + "\"");
            sb.Append(",\"customer_name\":\"" + dt.Rows[i]["customer_name"] + "\"");
            sb.Append(",\"customer_tel\":\"" + dt.Rows[i]["customer_tel"] + "\"");
            sb.Append(",\"customer_height\":\"" + dt.Rows[i]["customer_height"] + "\"");
            sb.Append(",\"customer_weight\":\"" + dt.Rows[i]["customer_weight"] + "\"");
            sb.Append(",\"iszf\":\"" + dt.Rows[i]["iszf"] + "\"");
            sb.Append(",\"customer_address\":\"" + dt.Rows[i]["customer_address"] + "\"");
            sb.Append(",\"cxordx\":\"" + dt.Rows[i]["cxordx"] + "\"");
            sb.Append(",\"xiaolei\":\"" + dt.Rows[i]["product_xiaolei"] + "\"");
            sb.Append(",\"isjj\":\"" + dt.Rows[i]["isjj"] + "\"");
            sb.Append(",\"jjfy\":\"" + dt.Rows[i]["jjfy"] + "\"");
            sb.Append(",\"jjts\":\"" + dt.Rows[i]["jjts"] + "\"");

            sb.Append(",\"product_value\":\"" + dt.Rows[i]["product_value"] + "\"");
            sb.Append(",\"product_name\":\"" + dt.Rows[i]["product_name"] + "\"");
            sb.Append(",\"product_size\":\"" + dt.Rows[i]["product_size"] + "\"");
            sb.Append(",\"product_price\":\"" + dt.Rows[i]["product_price"] + "\"");
            sb.Append(",\"product_count\":\"" + dt.Rows[i]["product_count"] + "\"");
            sb.Append(",\"fabric_brand\":\"" + dt.Rows[i]["fabric_brand"] + "\"");
            sb.Append(",\"fabric_code\":\"" + dt.Rows[i]["fabric_code"] + "\"");
            sb.Append(",\"factory_mat\":\"" + dt.Rows[i]["factory_mat"] + "\"");
            sb.Append(",\"use_mat\":\"" + dt.Rows[i]["use_mat"] + "\"");
            sb.Append(",\"order_date\":\"" + dt.Rows[i]["order_date"] + "\"");
            sb.Append(",\"delivery_date\":\"" + dt.Rows[i]["delivery_date"] + "\"");
            sb.Append(",\"lx_picurl\":\"" + dt.Rows[i]["lx_picurl"] + "\"");
            sb.Append(",\"lx_picid\":\"" + dt.Rows[i]["lx_picid"] + "\"");
            sb.Append(",\"lx_piccode\":\"" + dt.Rows[i]["lx_piccode"] + "\"");
            sb.Append(",\"lx_picname\":\"" + dt.Rows[i]["lx_picname"] + "\"");
            sb.Append(",\"xk_picurl\":\"" + dt.Rows[i]["xk_picurl"] + "\"");
            sb.Append(",\"xk_picid\":\"" + dt.Rows[i]["xk_picid"] + "\"");
            sb.Append(",\"xk_piccode\":\"" + dt.Rows[i]["xk_piccode"] + "\"");
            sb.Append(",\"xk_picname\":\"" + dt.Rows[i]["xk_picname"] + "\"");
            sb.Append(",\"qmj_picurl\":\"" + dt.Rows[i]["qmj_picurl"] + "\"");
            sb.Append(",\"qmj_picid\":\"" + dt.Rows[i]["qmj_picid"] + "\"");
            sb.Append(",\"qmj_piccode\":\"" + dt.Rows[i]["qmj_piccode"] + "\"");
            sb.Append(",\"qmj_picname\":\"" + dt.Rows[i]["qmj_picname"] + "\"");
            sb.Append(",\"xb_picurl\":\"" + dt.Rows[i]["xb_picurl"] + "\"");
            sb.Append(",\"xb_picid\":\"" + dt.Rows[i]["xb_picid"] + "\"");
            sb.Append(",\"xb_piccode\":\"" + dt.Rows[i]["xb_piccode"] + "\"");
            sb.Append(",\"xb_picname\":\"" + dt.Rows[i]["xb_picname"] + "\"");
            sb.Append(",\"hb_picurl\":\"" + dt.Rows[i]["hb_picurl"] + "\"");
            sb.Append(",\"hb_picid\":\"" + dt.Rows[i]["hb_picid"] + "\"");
            sb.Append(",\"hb_piccode\":\"" + dt.Rows[i]["hb_piccode"] + "\"");
            sb.Append(",\"hb_picname\":\"" + dt.Rows[i]["hb_picname"] + "\"");
            sb.Append(",\"kd_picurl\":\"" + dt.Rows[i]["kd_picurl"] + "\"");
            sb.Append(",\"kd_picid\":\"" + dt.Rows[i]["kd_picid"] + "\"");
            sb.Append(",\"kd_piccode\":\"" + dt.Rows[i]["kd_piccode"] + "\"");
            sb.Append(",\"kd_picname\":\"" + dt.Rows[i]["kd_picname"] + "\"");
            sb.Append(",\"lcp_picurl\":\"" + dt.Rows[i]["lcp_picurl"] + "\"");
            sb.Append(",\"lcp_picid\":\"" + dt.Rows[i]["lcp_picid"] + "\"");
            sb.Append(",\"lcp_piccode\":\"" + dt.Rows[i]["lcp_piccode"] + "\"");
            sb.Append(",\"lcp_picname\":\"" + dt.Rows[i]["lcp_picname"] + "\"");
            sb.Append(",\"xhbw_picurl\":\"" + dt.Rows[i]["xhbw_picurl"] + "\"");
            sb.Append(",\"xhbw_picid\":\"" + dt.Rows[i]["xhbw_picid"] + "\"");
            sb.Append(",\"xhbw_piccode\":\"" + dt.Rows[i]["xhbw_piccode"] + "\"");
            sb.Append(",\"xhbw_picname\":\"" + dt.Rows[i]["xhbw_picname"] + "\"");
            sb.Append(",\"xhzt_picurl\":\"" + dt.Rows[i]["xhzt_picurl"] + "\"");
            sb.Append(",\"xhzt_picid\":\"" + dt.Rows[i]["xhzt_picid"] + "\"");
            sb.Append(",\"xhzt_piccode\":\"" + dt.Rows[i]["xhzt_piccode"] + "\"");
            sb.Append(",\"xhzt_picname\":\"" + dt.Rows[i]["xhzt_picname"] + "\"");
            sb.Append(",\"xhys_picurl\":\"" + dt.Rows[i]["xhys_picurl"] + "\"");
            sb.Append(",\"xhys_picid\":\"" + dt.Rows[i]["xhys_picid"] + "\"");
            sb.Append(",\"xhys_piccode\":\"" + dt.Rows[i]["xhys_piccode"] + "\"");
            sb.Append(",\"xhys_picname\":\"" + dt.Rows[i]["xhys_picname"] + "\"");
            sb.Append(",\"xh_remark\":\"" + PageBase.ConvertString(dt.Rows[i]["xh_remark"].ToString()) + "\"");
            sb.Append(",\"gy_nkid\":\"" + dt.Rows[i]["gy_nkid"] + "\"");
            sb.Append(",\"gy_mjid\":\"" + dt.Rows[i]["gy_mjid"] + "\"");
            sb.Append(",\"gy_lzid\":\"" + dt.Rows[i]["gy_lzid"] + "\"");
            sb.Append(",\"gy_xkid\":\"" + dt.Rows[i]["gy_xkid"] + "\"");
            sb.Append(",\"remark\":\"" +PageBase.ConvertString(dt.Rows[i]["remark"].ToString()) + "\"");
            sb.Append(",\"createtime\":\"" + dt.Rows[i]["createtime"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("],");
        //尺码信息
        string sql_cm = @"select  a.id, a.docno, a.cmid,c.bwothername,c.publicerrand,c.maxvalue,c.minvalue,b.value,
                          a.ggcc, dbo.ClearZero(a.cycc) cycc, a.isactive  from t_order_cm a
                         left join t_cm_config b on a.cmid=b.id 
						 left join [t_bw_config] c on b.bwid=c.id where docno='{0}'";
        sql_cm = string.Format(sql_cm,dt.Rows[0]["docno"]);
        DataTable dt_cm = DBHelper.ExecuteDataTable(sql_cm);
        sb.Append("\"data_cm\":[");
        for (int j = 0; j < dt_cm.Rows.Count; j++)
        {
            sb.Append("{\"id\":\"" + dt_cm.Rows[j]["id"].ToString() + "\",");
            sb.Append("\"docno\":\"" + dt_cm.Rows[j]["docno"].ToString() + "\",");
            sb.Append("\"cmid\":\"" + dt_cm.Rows[j]["cmid"].ToString() + "\",");
            sb.Append("\"ggxz\":\"" + dt_cm.Rows[j]["ggcc"].ToString() + "\",");
            sb.Append("\"bwothername\":\"" + dt_cm.Rows[j]["bwothername"].ToString() + "\",");
            sb.Append("\"publicerrand\":\"" + dt_cm.Rows[j]["publicerrand"].ToString() + "\",");
            sb.Append("\"maxvalue\":\"" + dt_cm.Rows[j]["maxvalue"].ToString() + "\",");
            sb.Append("\"minvalue\":\"" + dt_cm.Rows[j]["minvalue"].ToString() + "\",");
            sb.Append("\"value\":\"" + dt_cm.Rows[j]["value"].ToString() + "\",");
            sb.Append("\"cycc\":\"" + dt_cm.Rows[j]["cycc"].ToString() + "\",");
            sb.Append("\"isactive\":\"" + dt_cm.Rows[j]["isactive"].ToString() + "\"}");
            if (j < dt_cm.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("],");
        //特体尺码信息
        string sql_ttcm = @"select a.id,a.docno,a.tdid,b.sbname,b.maxvalue,b.minvalue,a.tdmc,tdcc from t_order_tdcm a
                            left join t_SpecialBody b on a.tdid=b.id where docno='{0}'
							order by b.xh";
        sql_ttcm = string.Format(sql_ttcm,dt.Rows[0]["docno"]);
        DataTable dt_ttcm = DBHelper.ExecuteDataTable(sql_ttcm);
        sb.Append("\"data_ttcm\":[");
        for (int k = 0; k < dt_ttcm.Rows.Count; k++)
        {
            sb.Append("{\"id\":\"" + dt_ttcm.Rows[k]["id"].ToString() + "\",");
            sb.Append("\"docno\":\"" + dt_ttcm.Rows[k]["docno"].ToString() + "\",");
            sb.Append("\"tdid\":\"" + dt_ttcm.Rows[k]["tdid"].ToString() + "\",");
            sb.Append("\"sbname\":\"" + dt_ttcm.Rows[k]["sbname"].ToString() + "\",");
            sb.Append("\"maxvalue\":\"" + dt_ttcm.Rows[k]["maxvalue"].ToString() + "\",");
            sb.Append("\"minvalue\":\"" + dt_ttcm.Rows[k]["minvalue"].ToString() + "\",");
            sb.Append("\"tdmc\":\"" + dt_ttcm.Rows[k]["tdmc"].ToString() + "\",");
            sb.Append("\"tdcc\":\"" + dt_ttcm.Rows[k]["tdcc"].ToString() + "\"}");
            if (k < dt_ttcm.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("],");
        //备注图片信息
        string sql_bzpic = @"select id,docno,picurl from t_order_pic where docno='{0}'";
        sql_bzpic = string.Format(sql_bzpic,dt.Rows[0]["docno"]);
        DataTable dt_pic = DBHelper.ExecuteDataTable(sql_bzpic);
        sb.Append("\"data_pic\":[");
        for (int x = 0; x < dt_pic.Rows.Count; x++)
        {
            string urlgsh = "../"+dt_pic.Rows[x]["picurl"];
            sb.Append("{\"id\":\"" + dt_pic.Rows[x]["id"].ToString() + "\",");
            sb.Append("\"docno\":\"" + dt_pic.Rows[x]["docno"].ToString() + "\",");
            sb.Append("\"picurl\":\"" + urlgsh + "\"}");
            if (x < dt_pic.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //获取订单审核列表
    public void getinfo_shlist(HttpContext context)
    {
        //页数1
        int page = PageBase.ext_int(context.Request.Params["page"]);
        //每页条数10
        int limit =PageBase.ext_int(context.Request.Params["limit"]);
        //排序字段
        string field =PageBase.ext_string(context.Request.Params["field"]);
        //排序方式
        string order = PageBase.ext_string(context.Request.Params["order"]);
        //用户id
        string userid = PageBase.ext_string(context.Request.Params["userid"]);

        string orderby = "createtime desc";
        string where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,a.id,a.docno,a.ld_docno,a.store_name,a.customer_name,a.product_value,a.product_count,a.use_mat,a.status,
                       a.isactive,a.createtime,b.username,a.zhczrname,a.zhcztime from [t_order_main] a left join sys_users b on a.creater_id=b.id where a.isactive='Y'
                       and 1=1 ";

        string lddocno =PageBase.ext_string(context.Request.Params["lddocno"]);
        string dcname =PageBase.ext_string(context.Request.Params["dcname"]);
        string gkname =PageBase.ext_string(context.Request.Params["gkname"]);
        string status =PageBase.ext_string(context.Request.Params["status"]);
        //string lczt =PageBase.ext_string(context.Request.Params["lczt"]);
        ////流程状态
        //if (!string.IsNullOrEmpty(lczt))
        //{
        //    where += " and a.docno in(select distinct docno from workflow_currentoperator where userid="+userid+" and  isremark="+lczt+")";
        //}
        //else
        //{
        //    where += " and a.docno in(select distinct docno from workflow_currentoperator where userid="+userid+")";
        //}
        //量订单号
        if (!string.IsNullOrEmpty(lddocno))
        {
            where += " and a.ld_docno like N'%" + lddocno + "%'";
        }
        //店铺名称
        if (!string.IsNullOrEmpty(dcname))
        {
            where += " and a.store_name like N'%" + dcname + "%'";
        }
        //顾客名称
        if (!string.IsNullOrEmpty(gkname))
        {
            where += " and a.customer_name like N'%" + gkname + "%'";
        }
        //状态
        if (!string.IsNullOrEmpty(status))
        {
            where += " and a.status=" + status + "";
        }
        if (!string.IsNullOrEmpty(order) && !string.IsNullOrEmpty(field))
        {
            orderby =field + " " + order;
        }
        DataTable dt =  DBHelper.Pagination2(where, limit, page, orderby, "");
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        int count = 0;
        if(dt.Rows.Count>0)
            count = PageBase.ext_int(dt.Rows[0]["TOTAL"].ToString());

        sb.Append("{\"code\":\"" + code + "\",\"count\":" + count + ",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"docno\":\"" + dt.Rows[i]["docno"] + "\"");
            sb.Append(",\"ld_docno\":\"" + dt.Rows[i]["ld_docno"] + "\"");
            sb.Append(",\"store_name\":\"" + dt.Rows[i]["store_name"] + "\"");
            sb.Append(",\"customer_name\":\"" + dt.Rows[i]["customer_name"] + "\"");
            sb.Append(",\"product_value\":\"" + dt.Rows[i]["product_value"] + "\"");
            sb.Append(",\"product_count\":\"" + dt.Rows[i]["product_count"] + "\"");
            sb.Append(",\"use_mat\":\"" + dt.Rows[i]["use_mat"] + "\"");
            sb.Append(",\"status\":\"" + dt.Rows[i]["status"] + "\"");
            sb.Append(",\"isactive\":\"" + dt.Rows[i]["isactive"] + "\"");
            sb.Append(",\"username\":\"" + dt.Rows[i]["username"] + "\"");
            sb.Append(",\"zhczrname\":\"" + dt.Rows[i]["zhczrname"] + "\"");
            sb.Append(",\"zhcztime\":\"" + dt.Rows[i]["zhcztime"] + "\"");
            sb.Append(",\"createtime\":\"" + dt.Rows[i]["createtime"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //获取订单列表
    public void getinfo_list(HttpContext context)
    {
        //页数1
        int page = PageBase.ext_int(context.Request.Params["page"]);
        //每页条数10
        int limit =PageBase.ext_int(context.Request.Params["limit"]);
        //排序字段
        string field =PageBase.ext_string(context.Request.Params["field"]);
        //排序方式
        string order = PageBase.ext_string(context.Request.Params["order"]);
        //用户id
        string userid = PageBase.ext_string(context.Request.Params["userid"]);
        //用户id
        string islookme = PageBase.ext_string(context.Request.Params["islookmes"]);

        string orderby = "createtime desc";

        string where = "";
        if (islookme == "Y")
        {
            string sql_storeids = @"select manage_storeid from sys_users where id ="+userid+"";
            DataTable dt_storeids= DBHelper.ExecuteDataTable(sql_storeids);
            string storeids = dt_storeids.Rows[0]["manage_storeid"].ToString();
            where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,a.id,a.docno,a.ld_docno,a.store_name,
                             a.customer_name,a.product_value,a.product_count,a.status,
                       a.isactive,a.createtime,b.username,a.zhczrname,a.zhcztime from [t_order_main] a left join sys_users b on a.creater_id=b.id where a.isactive='Y'
                       and 1=1 and a.store_id in(select * from dbo.GetInStr('{0}')) ";
            where = string.Format(where, storeids);
        }
        else
        {
            where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,a.id,a.docno,a.ld_docno,a.store_name,
                             a.customer_name,a.product_value,a.product_count,a.status,
                       a.isactive,a.createtime,b.username,a.zhczrname,a.zhcztime from [t_order_main] a left join sys_users b on a.creater_id=b.id where a.isactive='Y'
                       and 1=1 and a.creater_id={0} ";
            where = string.Format(where,userid);
        }
        string lddocno =PageBase.ext_string(context.Request.Params["lddocno"]);
        string dcname =PageBase.ext_string(context.Request.Params["dcname"]);
        string gkname =PageBase.ext_string(context.Request.Params["gkname"]);
        string status =PageBase.ext_string(context.Request.Params["status"]);
        //string lczt =PageBase.ext_string(context.Request.Params["lczt"]);
        ////流程状态
        //if (!string.IsNullOrEmpty(lczt))
        //{
        //    where += " and a.docno in(select distinct docno from workflow_currentoperator where userid="+userid+" and  isremark="+lczt+")";
        //}
        //else
        //{
        //    where += " and a.docno in(select distinct docno from workflow_currentoperator where userid="+userid+")";
        //}
        //量订单号
        if (!string.IsNullOrEmpty(lddocno))
        {
            where += " and a.ld_docno like N'%" + lddocno + "%'";
        }
        //店铺名称
        if (!string.IsNullOrEmpty(dcname))
        {
            where += " and a.store_name like N'%" + dcname + "%'";
        }
        //顾客名称
        if (!string.IsNullOrEmpty(gkname))
        {
            where += " and a.customer_name like N'%" + gkname + "%'";
        }
        //状态
        if (!string.IsNullOrEmpty(status))
        {
            where += " and a.status=" + status + "";
        }
        if (!string.IsNullOrEmpty(order) && !string.IsNullOrEmpty(field))
        {
            orderby =field + " " + order;
        }
        DataTable dt =  DBHelper.Pagination2(where, limit, page, orderby, "");
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        int count = 0;
        if(dt.Rows.Count>0)
            count = PageBase.ext_int(dt.Rows[0]["TOTAL"].ToString());

        sb.Append("{\"code\":\"" + code + "\",\"count\":" + count + ",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"docno\":\"" + dt.Rows[i]["docno"] + "\"");
            sb.Append(",\"ld_docno\":\"" + dt.Rows[i]["ld_docno"] + "\"");
            sb.Append(",\"store_name\":\"" + dt.Rows[i]["store_name"] + "\"");
            sb.Append(",\"customer_name\":\"" + dt.Rows[i]["customer_name"] + "\"");
            sb.Append(",\"product_value\":\"" + dt.Rows[i]["product_value"] + "\"");
            sb.Append(",\"product_count\":\"" + dt.Rows[i]["product_count"] + "\"");
            sb.Append(",\"status\":\"" + dt.Rows[i]["status"] + "\"");
            sb.Append(",\"isactive\":\"" + dt.Rows[i]["isactive"] + "\"");
            sb.Append(",\"username\":\"" + dt.Rows[i]["username"] + "\"");
            sb.Append(",\"zhczrname\":\"" + dt.Rows[i]["zhczrname"] + "\"");
            sb.Append(",\"zhcztime\":\"" + dt.Rows[i]["zhcztime"] + "\"");
            sb.Append(",\"createtime\":\"" + dt.Rows[i]["createtime"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }

    //新增
    public void order_save(HttpContext context)
    {
        string msg = "";
        string sqlsave = "";
        string djbh = "";
        bool flag=false;
        string zt = PageBase.ext_string(context.Request.Params["zt"]);
        int savecount = PageBase.ext_int(context.Request.Params["issave"]);

        if (savecount != 0)
        {
            djbh = PageBase.ext_string(context.Request.Params["djbhs"]);
            if (djbh != "")
            {
                string del = @"delete from [t_order_main] where docno='{0}';delete from [t_order_cm] where docno='{0}';
                               delete from [t_order_tdcm] where docno='{0}';delete from [t_order_pic] where docno='{0}';";
                del = string.Format(del, djbh);
                DBHelper.ExecuteNonQuery(del);
            }
        }
        else
        {
            //生成单号
            string sqldjbh = @"declare @BH INT;declare @MID varchar(50);SELECT @BH=ISNULL(MAX(RIGHT(docno,4)),0)+1 FROM 
t_order_main WHERE LEFT(docno,2)='SO' AND  RIGHT(LEFT(docno,8),6)=CONVERT(VARCHAR(10),GETDATE(),12);
set @MID='SO'+CONVERT(VARCHAR(10),GETDATE(),12)+CAST(right((10000+@BH),4) AS VARCHAR(20)) ;
SELECT @MID";
            DataTable dtResult = DBHelper.ExecuteDataTable(sqldjbh);
            djbh = dtResult.Rows[0][0].ToString();
        }

        GetDate list = new GetDate();
        using (System.IO.StreamReader sr = new System.IO.StreamReader(context.Request.InputStream))
        {
            string s = sr.ReadToEnd();
            list = new JavaScriptSerializer().Deserialize<GetDate>(s);
        }
        if (list.ArrayObj_main.Count > 0)
        {
            string id = Utility.Trim(list.ArrayObj_main[0].ID);
            string loginid = Utility.Trim(list.ArrayObj_main[0].LOGINID);
            string username = Utility.Trim(list.ArrayObj_main[0].USERNAME);
            string ysdh = Utility.Trim(list.ArrayObj_main[0].YSDH);
            string storeid = Utility.Trim(list.ArrayObj_main[0].STOREID);
            string mendian = Utility.Trim(list.ArrayObj_main[0].MENDIAN);
            string storecode = Utility.Trim(list.ArrayObj_main[0].STORECODE);
            string gkxm = Utility.Trim(list.ArrayObj_main[0].GKXM);
            string lxfs = Utility.Trim(list.ArrayObj_main[0].LXFS);
            string shengao = Utility.Trim(list.ArrayObj_main[0].SHENGAO);
            string tizhong = Utility.Trim(list.ArrayObj_main[0].TIZHONG);
            string iszf = Utility.Trim(list.ArrayObj_main[0].ISZF);
            string iszf_= iszf == "True" ? "Y" : "N";
            string isjj = Utility.Trim(list.ArrayObj_main[0].ISJJ);
            string isjj_= isjj == "True" ? "Y" : "N";
            string iscd = Utility.Trim(list.ArrayObj_main[0].ISCD);
            string iscd_= iscd == "True" ? "Y" : "N";
            string jjfy = Utility.Trim(list.ArrayObj_main[0].JJFY);
            string jjts = Utility.Trim(list.ArrayObj_main[0].JJTS);

            string address = Utility.Trim(list.ArrayObj_main[0].ADDRESS);
            string kh = Utility.Trim(list.ArrayObj_main[0].KH);
            string pm = Utility.Trim(list.ArrayObj_main[0].PM);
            string xiaolei = Utility.Trim(list.ArrayObj_main[0].XIAOLEI);
            string cm = Utility.Trim(list.ArrayObj_main[0].CM);
            decimal? jg =Utility.ToDecimal(Utility.Trim(list.ArrayObj_main[0].JG));
            int? sl =Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].SL));
            string mlpp = Utility.Trim(list.ArrayObj_main[0].MLPP);
            string mlbm = Utility.Trim(list.ArrayObj_main[0].MLBM);
            string gcmlh = Utility.Trim(list.ArrayObj_main[0].GCMLH);
            decimal? ylms = Utility.ToDecimal(Utility.Trim(list.ArrayObj_main[0].YLMS));
            string dhrq = Utility.Trim(list.ArrayObj_main[0].DHRQ);
            string jhrq = Utility.Trim(list.ArrayObj_main[0].JHRQ);


            int? gy_nkid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].GY_NKID));
            int? gy_mjid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].GY_MJID));
            int? gy_lzid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].GY_LZID));
            int? gy_xkid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].GY_XKID));

            string lxpic = Utility.Trim(list.ArrayObj_main[0].LXPIC);
            int? lxid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].LXID));
            string lxbh = Utility.Trim(list.ArrayObj_main[0].LXBH);
            string lxmc = Utility.Trim(list.ArrayObj_main[0].LXMC);

            string xkpic = Utility.Trim(list.ArrayObj_main[0].XKPIC);
            int? xkid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].XKID));
            string xkbh = Utility.Trim(list.ArrayObj_main[0].XKBH);
            string xkmc = Utility.Trim(list.ArrayObj_main[0].XKMC);

            string qmjpic = Utility.Trim(list.ArrayObj_main[0].QMJPIC);
            int? qmjid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].QMJID));
            string qmjbh = Utility.Trim(list.ArrayObj_main[0].QMJBH);
            string qmjmc = Utility.Trim(list.ArrayObj_main[0].QMJMC);

            string xbpic = Utility.Trim(list.ArrayObj_main[0].XBPIC);
            int? xbid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].XBID));
            string xbbh = Utility.Trim(list.ArrayObj_main[0].XBBH);
            string xbmc = Utility.Trim(list.ArrayObj_main[0].XBMC);

            string hbpic = Utility.Trim(list.ArrayObj_main[0].HBPIC);
            int?  hbid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].HBID));
            string hbbh = Utility.Trim(list.ArrayObj_main[0].HBBH);
            string hbmc = Utility.Trim(list.ArrayObj_main[0].HBMC);

            string kdpic = Utility.Trim(list.ArrayObj_main[0].KDPIC);
            int?  kdid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].KDID));
            string kdbh = Utility.Trim(list.ArrayObj_main[0].KDBH);
            string kdmc = Utility.Trim(list.ArrayObj_main[0].KDMC);

            string lcppic = Utility.Trim(list.ArrayObj_main[0].LCPPIC);
            int?  lcpid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].LCPID));
            string lcpbh = Utility.Trim(list.ArrayObj_main[0].LCPBH);
            string lcpmc = Utility.Trim(list.ArrayObj_main[0].LCPMC);

            string xhbwpic = Utility.Trim(list.ArrayObj_main[0].XHBWPIC);
            int? xhbwid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].XHBWID));
            string xhbwbh = Utility.Trim(list.ArrayObj_main[0].XHBWBH);
            string xhbwmc = Utility.Trim(list.ArrayObj_main[0].XHBWMC);


            string xhztpic = Utility.Trim(list.ArrayObj_main[0].XHZTPIC);
            int?  xhztid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].XHZTID));
            string xhztbh = Utility.Trim(list.ArrayObj_main[0].XHZTBH);
            string xhztmc = Utility.Trim(list.ArrayObj_main[0].XHZTMC);

            string xhyspic = Utility.Trim(list.ArrayObj_main[0].XHYSPIC);
            int?  xhysid = Utility.ToInt(Utility.Trim(list.ArrayObj_main[0].XHYSID));
            string xhysbh = Utility.Trim(list.ArrayObj_main[0].XHYSBH);
            string xhysmc = Utility.Trim(list.ArrayObj_main[0].XHYSMC);

            string txt_xh_remark = Utility.Trim(list.ArrayObj_main[0].TXT_XH_REMARK);
            string txt_other_remark = Utility.Trim(list.ArrayObj_main[0].TXT_OTHER_REMARK);
            string pic_urls = Utility.Trim(list.ArrayObj_main[0].PIC_URLS);


            if (djbh != "" && djbh != null)
            {
                int status = 0;
                string nodexh = "";
                if(zt == "tj")
                {
                    nodexh = "01";
                }

                //主体信息
                sqlsave = @"INSERT INTO [t_order_main]
                                   (docno, ld_docno, store_docno, store_name, customer_name, 
      customer_tel, customer_height, customer_weight,iszf, customer_address, product_value, 
      product_name, product_size, product_price, product_count, fabric_brand, fabric_code, 
      factory_mat, use_mat, order_date, delivery_date, lx_picid, lx_picurl, lx_piccode, 
      lx_picname, xk_picid, xk_picurl, xk_piccode, xk_picname, qmj_picid, qmj_picurl, 
      qmj_piccode, qmj_picname, xb_picid, xb_picurl, xb_piccode, xb_picname, hb_picid, 
      hb_picurl, hb_piccode, hb_picname, kd_picid, kd_picurl, kd_piccode, kd_picname, 
      lcp_picid, lcp_picurl, lcp_piccode, lcp_picname, 
      xhbw_picid, xhbw_picurl, xhbw_piccode, xhbw_picname, xhzt_picid, xhzt_picurl, 
      xhzt_piccode, xhzt_picname, xhys_picid, xhys_picurl, xhys_piccode, xhys_picname, xh_remark, 
      remark, isactive, creater_id, createtime, reviser_id, revisiontime,status,zt,zhczrid,zhczrname,zhcztime,store_id,isjj,jjts,jjfy,
      gy_nkid,gy_mjid,gy_lzid,gy_xkid,cxordx,product_xiaolei)
                             VALUES
                ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}',
'{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}','{38}','{39}','{40}',
'{41}','{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}','{51}','{52}','{53}','{54}','{55}','{56}','{57}','{58}','{59}','{60}','{61}',
'{62}','{63}','{64}','{65}','{66}','{67}','{68}','{69}','{70}','{71}','{72}','{73}','{74}','{75}','{76}','{77}','{78}','{79}','{80}','{81}','{82}'
                                  );";
                sqlsave = string.Format(sqlsave, djbh, ysdh, storecode, mendian, gkxm, lxfs, shengao, tizhong,iszf_, address, kh, pm, cm, jg, sl,mlpp, mlbm, gcmlh, ylms, dhrq, jhrq,
                    lxid,lxpic,lxbh,lxmc,xkid,xkpic,xkbh,xkmc,qmjid,qmjpic,qmjbh,qmjmc,xbid,xbpic,xbbh,xbmc,hbid,hbpic,hbbh,hbmc,kdid,kdpic,kdbh,kdmc,lcpid,lcppic,lcpbh,lcpmc,
                    xhbwid,xhbwpic,xhbwbh,xhbwmc,xhztid, xhztpic,xhztbh,xhztmc,xhysid, xhyspic,xhysbh,xhysmc,
                    txt_xh_remark, txt_other_remark, "Y", id, DateTime.Now.ToString(),id, DateTime.Now.ToString(),
                    status,nodexh,id,username,DateTime.Now.ToString(),storeid,isjj_,jjts,jjfy,gy_nkid,gy_mjid,gy_lzid,gy_xkid,iscd_,xiaolei);

                //图片，先去除最后一个符号
                string[] pic_url = { };
                if (pic_urls != "")
                {
                    pic_url = pic_urls.TrimEnd('|').Split('|');
                    foreach (string p in pic_url)
                    {
                        if (p != "" && p != null)
                        {
                            sqlsave += @"insert into t_order_pic(docno, picurl, isactive) values('{0}','{1}','{2}');";
                            sqlsave = string.Format(sqlsave, djbh, p, "Y");
                        }
                    }
                }
                //尺码信息
                for (int i = 0; i < list.ArrayObj_cm.Count; i++)
                {
                    sqlsave += @"insert into t_order_cm(docno, cmid, ggcc,cycc, isactive) values('{0}','{1}','{2}','{3}','{4}');";
                    string bwid = Utility.Trim(list.ArrayObj_cm[i].BWID);
                    string ggxz = Utility.Trim(list.ArrayObj_cm[i].GGXZ);
                    decimal? value = Utility.ToDecimal(Utility.Trim(list.ArrayObj_cm[i].CMVALUE));
                    sqlsave = string.Format(sqlsave, djbh, bwid, ggxz, value, "Y");
                }
                //特体尺码信息
                for (int j = 0; j < list.ArrayObj_ttcm.Count; j++)
                {
                    sqlsave += @"insert into t_order_tdcm(docno, tdid, tdmc, tdcc, isactive) values('{0}','{1}','{2}','{3}','{4}');";
                    string ttid = Utility.Trim(list.ArrayObj_ttcm[j].ID);
                    string value =Utility.Trim(list.ArrayObj_ttcm[j].TTCMVALUE);
                    sqlsave = string.Format(sqlsave, djbh, ttid, "1", value, "Y");
                }
                //插入数据库条数
                int zxcount = 0;
                try
                {
                    zxcount = DBHelper.ExecuteNonQuery(sqlsave);
                }
                catch (Exception e)
                {
                    flag = false;
                    msg = e.Message;
                }
                //计算前台传过来的数据条数
                int zqts = 0;
                if (pic_urls == "")
                {
                    zqts = list.ArrayObj_main.Count + list.ArrayObj_cm.Count + list.ArrayObj_ttcm.Count;
                }
                else
                {
                    zqts = list.ArrayObj_main.Count + pic_url.Length + list.ArrayObj_cm.Count + list.ArrayObj_ttcm.Count;
                }
                if (zxcount == zqts)
                {
                    flag = true;
                    //string sql_zt = @"exec [zdy_更新操作步骤] '{0}','{1}','{2}'";

                    if (zt == "tj")
                    {
                        msg = "提交成功";
                        //sql_zt = string.Format(sql_zt, djbh, "提交",id);
                        string sql_zt = @"insert into t_order_mainlog(docno,cz,czrid,czrname,cztime,remark) values('{0}','{1}','{2}','{3}','{4}','{5}');
                                          update t_order_main set status=1 where docno='{0}';";
                        sql_zt = string.Format(sql_zt,djbh,"提交",id,username,DateTime.Now.ToString(),"");
                        DBHelper.ExecuteNonQuery(sql_zt);

                    }

                    else
                    {
                        msg = "保存成功";
                        //sql_zt = string.Format(sql_zt, djbh, "保存",id);
                        string sql_zt = @"insert into t_order_mainlog(docno,cz,czrid,czrname,cztime,remark) values('{0}','{1}','{2}','{3}','{4}','{5}')";
                        sql_zt = string.Format(sql_zt,djbh,"保存",id,username,DateTime.Now.ToString(),"");
                        DBHelper.ExecuteNonQuery(sql_zt);
                    }

                }
                else
                {
                    //如果新增失败，清除所有数据
                    string sqldel = @"delete from [t_order_main] where docno='{0}';delete from [t_order_cm] where docno='{0}';
                            delete from [t_order_tdcm] where docno='{0}';delete from [t_order_pic] where docno='{0}';";
                    sqldel = string.Format(sqldel, djbh);
                    DBHelper.ExecuteNonQuery(sqldel);
                    flag = false;
                    if (zt == "tj")
                        msg = "提交失败，请联系管理员";
                    else
                        msg = "保存失败，请联系管理员";

                }
            }
            else
            {
                flag = false;
                if (zt == "tj")
                    msg = "提交失败，请联系管理员";
                else
                    msg = "保存失败，请联系管理员";
            }
        }
        else
        {
            flag = false;
            if (zt == "tj")
                msg = "提交失败，请联系管理员";
            else
                msg = "保存失败，请联系管理员";
        }
        context.Response.Write("{\"flag\":\"" + flag + "\",\"remsg\":\"" + msg + "\",\"djbh\":\"" + djbh + "\"}");
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //根据工厂面料号获取面料编码
    public void getinfo_getmlbm(HttpContext context)
    {
        string gcmlh = PageBase.ext_string(context.Request.Params["gcmlh"]);
        string sql = @"exec [zdy_根据工厂面料号查询面料编码] '{0}'";
        sql = string.Format(sql, gcmlh);
        DataTable dt = DBHelper.ExecuteDataTable(sql);
        sb = new StringBuilder();
        sb.Append("{\"code\":\"" + dt.Rows[0]["recode"].ToString() + "\",\"mlbm\":\"" + dt.Rows[0]["mlbm"].ToString() + "\",\"mlpp\":\"" + dt.Rows[0]["mlpp"].ToString() + "\"}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //获取特体信息
    public void getinfo_othercm(HttpContext context)
    {
        string sql = @"select id, xh, sbcode, sbname, maxvalue, minvalue, isactive, createtime from t_SpecialBody where isactive='Y' order by xh";
        DataTable dt = DBHelper.ExecuteDataTable(sql);
        string fsmessage = "";
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"xh\":\"" + dt.Rows[i]["xh"] + "\"");
            sb.Append(",\"sbcode\":\"" + dt.Rows[i]["sbcode"] + "\"");
            sb.Append(",\"sbname\":\"" + dt.Rows[i]["sbname"] + "\"");
            sb.Append(",\"maxvalue\":\"" + dt.Rows[i]["maxvalue"] + "\"");
            sb.Append(",\"minvalue\":\"" + dt.Rows[i]["minvalue"] + "\"");
            sb.Append(",\"isactive\":\"" + dt.Rows[i]["isactive"] + "\"");
            sb.Append(",\"createtime\":\"" + dt.Rows[i]["createtime"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //根据尺码id获取尺码信息
    public void getinfo_cmbysel(HttpContext context)
    {
        string cmid = PageBase.ext_string(context.Request.Params["cmid"]);
        string cxordx = PageBase.ext_string(context.Request.Params["cxordx"]);
        string cxordx_= cxordx == "true" ? "长" : "短";
        string hbname = PageBase.ext_string(context.Request.Params["hbname"]);

        string sql = @"select a.id,a.value,a.isactive,b.id bwid,b.bwname,b.bwothername,b.publicerrand,b.maxvalue,b.minvalue
                      from [dbo].t_cm_config a left join [t_bw_config] b on a.bwid=b.id where a.cmid={0} and a.isactive='Y'";
        if (cxordx == "true" )
        {
            if (hbname == "双省")
            {
                sql += " and b.bwname in('成品领圈','胸围','腰围（收省）','下摆围','肩宽','袖长','袖肥','袖克夫长','后衣长（圆摆）','后背宽')";
            }
            else
            {
                sql += " and b.bwname in('成品领圈','胸围','腰围','下摆围','肩宽','袖长','袖肥','袖克夫长','后衣长（圆摆）','后背宽')";
            }
        }
        else if (cxordx=="false")
        {
            if (hbname == "双省")
            {
                sql += " and b.bwname in('成品领圈','胸围','腰围（收省）','下摆围','肩宽','短袖长','短袖肥','短袖口','后衣长（圆摆）','后背宽')";
            }
            else
            {
                sql += " and b.bwname in('成品领圈','胸围','腰围','下摆围','肩宽','短袖长','短袖肥','短袖口','后衣长（圆摆）','后背宽')";
            }
        }
        else
        {
            if (hbname == "双省")
            {
                sql += " and b.bwname in('成品领圈','胸围','腰围（收省）','下摆围','肩宽','袖长','袖肥','袖克夫长','后衣长（圆摆）','后背宽')";
            }
            else
            {
                sql += " and b.bwname in('成品领圈','胸围','腰围','下摆围','肩宽','袖长','袖肥','袖克夫长','后衣长（圆摆）','后背宽')";
            }
        }
        sql += " order by b.xh";
        sql = string.Format(sql, cmid);
        DataTable dt = DBHelper.ExecuteDataTable(sql);

        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"bwothername\":\"" + dt.Rows[i]["bwothername"] + "\"");
            sb.Append(",\"value\":\"" + dt.Rows[i]["value"] + "\"");
            sb.Append(",\"isactive\":\"" + dt.Rows[i]["isactive"] + "\"");
            sb.Append(",\"bwid\":\"" + dt.Rows[i]["bwid"] + "\"");
            sb.Append(",\"maxvalue\":\"" + dt.Rows[i]["maxvalue"] + "\"");
            sb.Append(",\"minvalue\":\"" + dt.Rows[i]["minvalue"] + "\"");
            sb.Append(",\"publicerrand\":\"" + dt.Rows[i]["publicerrand"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //查询工艺下拉选项
    public void getinfo_zsgy(HttpContext context)
    {
        string gylx = PageBase.ext_string(context.Request.Params["gylx"]);
        string sql = @"select * from [dbo].t_pic where typeid in(select id from [dbo].[t_type] where remark='"+gylx+"') and isactive='Y' order by xh";
        DataTable dt = DBHelper.ExecuteDataTable(sql);
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"name\":\"" + dt.Rows[i]["name"] + "\"");
            sb.Append(",\"isactive\":\"" + dt.Rows[i]["isactive"] + "\"");
            sb.Append(",\"createtime\":\"" + dt.Rows[i]["createtime"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }

    //查询尺码下拉选项
    public void getinfo_cm(HttpContext context)
    {
        string sql = @"select * from t_size where isactive='Y' and cmgroup='正装衬衫类' order by xh";
        DataTable dt = DBHelper.ExecuteDataTable(sql);

        string fsmessage = "";
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"id\":\"" + dt.Rows[i]["id"].ToString() + "\"");
            sb.Append(",\"cmwm\":\"" + dt.Rows[i]["cmwm"] + "\"");
            sb.Append(",\"cmnm\":\"" + dt.Rows[i]["cmnm"] + "\"");
            sb.Append(",\"isactive\":\"" + dt.Rows[i]["isactive"] + "\"");
            sb.Append(",\"createtime\":\"" + dt.Rows[i]["createtime"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //查询图片信息
    public void getinfo_list_pic(HttpContext context)
    {
        string lxtype = PageBase.ext_string(context.Request.Params["lxtype"]);
        string cxordx = PageBase.ext_string(context.Request.Params["cxordx"]);
        string sql= @"select b.typename,b.remark,a.id,a.name,a.describe,a.imgurl from [dbo].[t_pic] a 
                       left join [t_type] b on a.typeid=b.id where b.remark='{0}' and a.isactive='Y' order by a.xh";

        if (lxtype == "xk" && cxordx=="false")
        {
            sql = string.Format(sql, "dxk");
        }
        else
        {
            sql = string.Format(sql, lxtype);
        }

        DataTable dt = DBHelper.ExecuteDataTable(sql);
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        sb.Append("{\"code\":\"" + code + "\",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string urlgsh = "../"+dt.Rows[i]["imgurl"];
            sb.Append("{\"typename\":\"" + dt.Rows[i]["typename"].ToString() + "\"");
            sb.Append(",\"id\":\"" + dt.Rows[i]["id"] + "\"");
            sb.Append(",\"name\":\"" + dt.Rows[i]["name"] + "\"");
            sb.Append(",\"describe\":\"" + dt.Rows[i]["describe"] + "\"");
            sb.Append(",\"imgurl\":\"" + urlgsh + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //查询量订单据
    public void getinfo_list_ysd(HttpContext context)
    {
        //页数1
        int page = PageBase.ext_int(context.Request.Params["page"]);
        //每页条数10
        int limit =PageBase.ext_int(context.Request.Params["limit"]);
        //排序字段
        string field =PageBase.ext_string(context.Request.Params["field"]);
        //排序方式
        string order = PageBase.ext_string(context.Request.Params["order"]);
        //用户id
        string userid = PageBase.ext_string(context.Request.Params["userid"]);


        string sql_lddj = "exec [zdy_查询量定单据_new] '{0}'";
        sql_lddj = string.Format(sql_lddj, userid);
        DBHelper.ExecuteNonQuery(sql_lddj);


        string orderby = "billdate desc";
        string where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,id,docno,billdate,storeid,code,name,address,
                       ld_flag from [t_量定单据_查询]  where  1=1  ";

        string lddocno = PageBase.ext_string(context.Request.Params["lddocno"]);
        string dcname = PageBase.ext_string(context.Request.Params["dcname"]);
        //string gkname =PageBase.ext_string(context.Request.Params["gkname"]);
        //string status =PageBase.ext_string(context.Request.Params["status"]);
        //量订单号不为空
        if (!string.IsNullOrEmpty(lddocno))
        {
            where += " and docno like N'%" + lddocno + "%'";
        }
        //店仓名称不为空
        else if (!string.IsNullOrEmpty(dcname) )
        {
            where += " and name like N'%" + dcname + "%'";
        }

        DataTable dt =  DBHelper.Pagination2(where, limit, page, orderby, "");
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        int count = 0;
        if(dt.Rows.Count>0)
            count = PageBase.ext_int(dt.Rows[0]["TOTAL"].ToString());


        sb.Append("{\"code\":\"" + code + "\",\"count\":" + count + ",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"docno\":\"" + dt.Rows[i]["docno"].ToString() + "\"");
            sb.Append(",\"id\":\"" + dt.Rows[i]["id"] + "\"");
            sb.Append(",\"billdate\":\"" + dt.Rows[i]["billdate"] + "\"");
            sb.Append(",\"storeid\":\"" + dt.Rows[i]["storeid"] + "\"");
            sb.Append(",\"code\":\"" + dt.Rows[i]["code"] + "\"");
            sb.Append(",\"name\":\"" + dt.Rows[i]["name"] + "\"");
            sb.Append(",\"address\":\"" + dt.Rows[i]["address"] + "\"");
            sb.Append(",\"ld_flag\":\"" + dt.Rows[i]["ld_flag"] + "\"}");
            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }
    //查询量订单据-oracle模式
    //public void getinfo_list_ysd(HttpContext context)
    //{
    //    string userid = PageBase.ext_string(context.Request.Params["userid"]);
    //    //页数1
    //    int page = PageBase.ext_int(context.Request.Params["page"]);
    //    //每页条数10
    //    //int limit =PageBase.ext_int(context.Request.Params["limit"]);
    //    int limit =10;
    //    var start = page * limit - limit + 1;//根据分页的页面去选择数据的开始因素
    //    var end = page * limit;//获得分页的最后因素
    //                           //排序字段
    //    string field =PageBase.ext_string(context.Request.Params["field"]);
    //    //排序方式
    //    string order = PageBase.ext_string(context.Request.Params["order"]);
    //    string orderby = "createtime ";
    //    if (!string.IsNullOrEmpty(order) && !string.IsNullOrEmpty(field))
    //    {
    //        orderby =field + " " + order;
    //    }

    //    string where = "";

    //    string sql_lddj = "exec [zdy_查询量定单据_new] '{0}'";
    //    sql_lddj = string.Format(sql_lddj,userid);
    //    DBHelper.ExecuteNonQuery(sql_lddj);


    //    string lddocno =PageBase.ext_string(context.Request.Params["lddocno"]);
    //    string dcname =PageBase.ext_string(context.Request.Params["dcname"]);
    //    //string gkname =PageBase.ext_string(context.Request.Params["gkname"]);
    //    //string status =PageBase.ext_string(context.Request.Params["status"]);
    //    //两个都不为空
    //    if (!string.IsNullOrEmpty(lddocno) && !string.IsNullOrEmpty(dcname))
    //    {
    //        where = "exec zdy_查询量定单据 '{0}','{1}','{2}','{3}','{4}',''";
    //        where = string.Format(where,lddocno,dcname,start,end,userid);
    //    }
    //    //量订单号不为空，店仓为空
    //    else if (!string.IsNullOrEmpty(lddocno) && string.IsNullOrEmpty(dcname))
    //    {
    //        where = "exec zdy_查询量定单据 '{0}','{1}','{2}','{3}','{4}',''";
    //        where = string.Format(where,lddocno,"",start,end,userid);
    //    }
    //    //量订单号为空，店仓不为空
    //    else if (string.IsNullOrEmpty(lddocno) && !string.IsNullOrEmpty(dcname))
    //    {
    //        where = "exec zdy_查询量定单据 '{0}','{1}','{2}','{3}','{4}',''";
    //        where = string.Format(where,"",dcname,start,end,userid);
    //    }
    //    //量订单号为空，店仓不为空
    //    else if (string.IsNullOrEmpty(lddocno) && string.IsNullOrEmpty(dcname))
    //    {
    //        where = "exec zdy_查询量定单据 '{0}','{1}','{2}','{3}','{4}',''";
    //        where = string.Format(where,"","",start,end,userid);
    //    }
    //    DataTable dt_all = DBHelper.ExecuteDataTable(where);

    //    //总数
    //    string strFilter_zs = @" ID = '-1.0'";
    //    DataTable dt_zs =PageBase.FilterdataTable( dt_all,strFilter_zs);
    //    int count = 0;
    //    if (dt_zs.Rows.Count > 0)
    //        count = PageBase.ext_int(dt_zs.Rows[0]["billdate"]);

    //    //分页后数据
    //    string strFilter = @"ID <>  '-1.0'";
    //    DataTable dt =PageBase.FilterdataTable(dt_all,strFilter);

    //    sb = new StringBuilder();
    //    string code = "0";
    //    string msg = "";
    //    sb.Append("{\"code\":\"" + code + "\",\"count\":" + count + ",\"msg\":\"" + msg + "\",\"data\":[");
    //    for (int i = 0; i < dt.Rows.Count; i++)
    //    {
    //        sb.Append("{\"docno\":\"" + dt.Rows[i]["docno"].ToString() + "\"");
    //        sb.Append(",\"id\":\"" + dt.Rows[i]["id"] + "\"");
    //        sb.Append(",\"billdate\":\"" + dt.Rows[i]["billdate"] + "\"");
    //        sb.Append(",\"storeid\":\"" + dt.Rows[i]["storeid"] + "\"");
    //        sb.Append(",\"code\":\"" + dt.Rows[i]["code"] + "\"");
    //        sb.Append(",\"name\":\"" + dt.Rows[i]["name"] + "\"");
    //        sb.Append(",\"address\":\"" + dt.Rows[i]["address"] + "\"");
    //        sb.Append(",\"ld_flag\":\"" + dt.Rows[i]["ld_flag"] + "\"}");
    //        if (i < dt.Rows.Count - 1)
    //        {
    //            sb.Append(",");
    //        }
    //    }
    //    sb.Append("]}");
    //    context.Response.Write(sb.ToString());
    //    context.Response.ContentType = "text/json";
    //    context.Response.End();
    //}
    //根据预收单查询款号信息
    public void getinfo_list_kh(HttpContext context)
    {
        string ysdid = PageBase.ext_string(context.Request.Params["ysdid"]);
        //页数1
        int page = PageBase.ext_int(context.Request.Params["page"]);
        //每页条数10
        int limit =PageBase.ext_int(context.Request.Params["limit"]);
        //排序字段
        string field =PageBase.ext_string(context.Request.Params["field"]);
        //排序方式
        string order = PageBase.ext_string(context.Request.Params["order"]);
        //用户id
        string userid = PageBase.ext_string(context.Request.Params["userid"]);


        string sql = @"exec zdy_查询预收单款号 '{0}'";
        sql = string.Format(sql, ysdid);
        DBHelper.ExecuteNonQuery(sql);


        string orderby = "value desc";
        //string where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,docno, storeid, dccode, dcname, address, khid, tmid, name, 
        //        value,xiaolei, qty, pricelist, priceactual, tot_amt_actual, discount, 
        //        value1_code, value1, value2_code, value2, mlbm, mlname, mlpp, 
        //        gcmlbm from [t_量定单据_明细]  where  1=1  and xiaolei like '%衬衫%'";

        string where = @"select  COUNT(*) OVER(PARTITION BY 1) AS TOTAL,docno, storeid, dccode, dcname, address, khid, tmid, name, 
                value,xiaolei, qty, pricelist, priceactual, tot_amt_actual, discount, 
                value1_code, value1, value2_code, value2, mlbm, mlname, mlpp, 
                gcmlbm from [t_量定单据_明细]  where  1=1  ";


        DataTable dt =  DBHelper.Pagination2(where, limit, page, orderby, "");
        sb = new StringBuilder();
        string code = "0";
        string msg = "";
        int count = 0;
        if(dt.Rows.Count>0)
            count = PageBase.ext_int(dt.Rows[0]["TOTAL"].ToString());

        sb.Append("{\"code\":\"" + code + "\",\"count\":" + count + ",\"msg\":\"" + msg + "\",\"data\":[");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sb.Append("{\"khid\":\"" + dt.Rows[i]["khid"].ToString() + "\"");
            sb.Append(",\"storeid\":\"" + dt.Rows[i]["storeid"] + "\"");
            sb.Append(",\"dccode\":\"" + dt.Rows[i]["dccode"] + "\"");
            sb.Append(",\"dcname\":\"" + dt.Rows[i]["dcname"] + "\"");
            sb.Append(",\"address\":\"" + dt.Rows[i]["address"] + "\"");
            sb.Append(",\"docno\":\"" + dt.Rows[i]["docno"] + "\"");
            sb.Append(",\"tmid\":\"" + dt.Rows[i]["tmid"] + "\"");
            sb.Append(",\"name\":\"" + dt.Rows[i]["name"] + "\"");
            sb.Append(",\"value\":\"" + dt.Rows[i]["value"] + "\"");
            sb.Append(",\"xiaolei\":\"" + dt.Rows[i]["xiaolei"] + "\"");
            sb.Append(",\"qty\":\"" + dt.Rows[i]["qty"] + "\"");
            sb.Append(",\"pricelist\":\"" + dt.Rows[i]["pricelist"] + "\"");
            sb.Append(",\"priceactual\":\"" + dt.Rows[i]["priceactual"] + "\"");
            sb.Append(",\"tot_amt_actual\":\"" + dt.Rows[i]["tot_amt_actual"] + "\"");
            sb.Append(",\"discount\":\"" + dt.Rows[i]["discount"] + "\"");
            sb.Append(",\"value1_code\":\"" + dt.Rows[i]["value1_code"] + "\"");
            sb.Append(",\"value1\":\"" + dt.Rows[i]["value1"] + "\"");
            sb.Append(",\"value2_code\":\"" + dt.Rows[i]["value2_code"] + "\"");
            sb.Append(",\"value2\":\"" + dt.Rows[i]["value2"] + "\"");
            sb.Append(",\"mlbm\":\"" + dt.Rows[i]["mlbm"] + "\"");
            sb.Append(",\"mlname\":\"" + dt.Rows[i]["mlname"] + "\"");
            sb.Append(",\"mlpp\":\"" + dt.Rows[i]["mlpp"] + "\"");
            sb.Append(",\"gcmlbm\":\"" + dt.Rows[i]["gcmlbm"] + "\"}");


            if (i < dt.Rows.Count - 1)
            {
                sb.Append(",");
            }
        }
        sb.Append("]}");
        context.Response.Write(sb.ToString());
        context.Response.ContentType = "text/json";
        context.Response.End();
    }

    public class GetDate
    {
        public List<main> ArrayObj_main { get; set; }//主表信息
        public List<cm> ArrayObj_cm { get; set; }//尺寸信息
        public List<ttcm> ArrayObj_ttcm { get; set; }//特体尺码信息
    }
    public class main
    {
        //用户id
        public string id;
        public string ID
        {
            get { return id; }
            set { id = value; }
        }
        //登录账户
        public string loginid;
        public string LOGINID
        {
            get { return loginid; }
            set { loginid = value; }
        }
        //用户名称
        public string username;
        public string USERNAME
        {
            get { return username; }
            set { username = value; }
        }
        //预收单号
        public string ysdh;
        public string YSDH
        {
            get { return ysdh; }
            set { ysdh = value; }
        }
        //门店id
        public string storeid;
        public string STOREID
        {
            get { return storeid; }
            set { storeid = value; }
        }
        //门店名称
        public string mendian;
        public string MENDIAN
        {
            get { return mendian; }
            set { mendian = value; }
        }
        //门店代码
        public string storecode;
        public string STORECODE
        {
            get { return storecode; }
            set { storecode = value; }
        }
        //顾客姓名
        public string gkxm;
        public string GKXM
        {
            get { return gkxm; }
            set { gkxm = value; }
        }
        //联系方式
        public string lxfs;
        public string LXFS
        {
            get { return lxfs; }
            set { lxfs = value; }
        }
        //身高
        public string shengao;
        public string SHENGAO
        {
            get { return shengao; }
            set { shengao = value; }
        }
        //体重
        public string tizhong;
        public string TIZHONG
        {
            get { return tizhong; }
            set { tizhong = value; }
        }
        //是否直发
        public string iszf;
        public string ISZF
        {
            get { return iszf; }
            set { iszf = value; }
        }
        //地址
        public string address;
        public string ADDRESS
        {
            get { return address; }
            set { address = value; }
        }
        //长短袖
        public string iscd;
        public string ISCD
        {
            get { return iscd; }
            set { iscd = value; }
        }
        //是否加急
        public string isjj;
        public string ISJJ
        {
            get { return isjj; }
            set { isjj = value; }
        }
        //加急天数
        public string jjts;
        public string JJTS
        {
            get { return jjts; }
            set { jjts = value; }
        }
        //加急费用
        public string jjfy;
        public string JJFY
        {
            get { return jjfy; }
            set { jjfy = value; }
        }
        //款号
        public string kh;
        public string KH
        {
            get { return kh; }
            set { kh = value; }
        }
        //品名
        public string pm;
        public string PM
        {
            get { return pm; }
            set { pm = value; }
        }
        //小类
        public string xiaolei;
        public string XIAOLEI
        {
            get { return xiaolei; }
            set { xiaolei = value; }
        }
        //尺码
        public string cm;
        public string CM
        {
            get { return cm; }
            set { cm = value; }
        }
        //价格
        public decimal? jg;
        public decimal? JG
        {
            get { return jg; }
            set { jg = value; }
        }
        //数量
        public int? sl;
        public int? SL
        {
            get { return sl; }
            set { sl = value; }
        }
        //面料品牌
        public string mlpp;
        public string MLPP
        {
            get { return mlpp; }
            set { mlpp = value; }
        }
        //面料部位
        public string mlbm;
        public string MLBM
        {
            get { return mlbm; }
            set { mlbm = value; }
        }
        //工厂面料号
        public string gcmlh;
        public string GCMLH
        {
            get { return gcmlh; }
            set { gcmlh = value; }
        }
        //用料米数
        public decimal? ylms;
        public decimal? YLMS
        {
            get { return ylms; }
            set { ylms = value; }
        }
        //订货日期
        public string dhrq;
        public string DHRQ
        {
            get { return dhrq; }
            set { dhrq = value; }
        }
        //交货日期
        public string jhrq;
        public string JHRQ
        {
            get { return jhrq; }
            set { jhrq = value; }
        }
        //领型图片
        public string lxpic;
        public string LXPIC
        {
            get { return lxpic; }
            set { lxpic = value; }
        }
        //领型图片id
        public int? lxid;
        public int? LXID
        {
            get { return lxid; }
            set { lxid = value; }
        }
        //领型编号
        public string lxbh;
        public string LXBH
        {
            get { return lxbh; }
            set { lxbh = value; }
        }
        //领型名称
        public string lxmc;
        public string LXMC
        {
            get { return lxmc; }
            set { lxmc = value; }
        }
        //袖口图片
        public string xkpic;
        public string XKPIC
        {
            get { return xkpic; }
            set { xkpic = value; }
        }
        //袖口图片id
        public int? xkid;
        public int? XKID
        {
            get { return xkid; }
            set { xkid = value; }
        }
        //袖口编号
        public string xkbh;
        public string XKBH
        {
            get { return xkbh; }
            set { xkbh = value; }
        }
        //袖口名称
        public string xkmc;
        public string XKMC
        {
            get { return xkmc; }
            set { xkmc = value; }
        }
        //前门襟图片
        public string qmjpic;
        public string QMJPIC
        {
            get { return qmjpic; }
            set { qmjpic = value; }
        }
        //前门襟图片id
        public int? qmjid;
        public int? QMJID
        {
            get { return qmjid; }
            set { qmjid = value; }
        }
        //前门襟编号
        public string qmjbh;
        public string QMJBH
        {
            get { return qmjbh; }
            set { qmjbh = value; }
        }
        //前门襟名称
        public string qmjmc;
        public string QMJMC
        {
            get { return qmjmc; }
            set { qmjmc = value; }
        }

        //下摆图片
        public string xbpic;
        public string XBPIC
        {
            get { return xbpic; }
            set { xbpic = value; }
        }
        //下摆图片id
        public int? xbid;
        public int? XBID
        {
            get { return xbid; }
            set { xbid = value; }
        }
        //下摆编号
        public string xbbh;
        public string XBBH
        {
            get { return xbbh; }
            set { xbbh = value; }
        }
        //下摆名称
        public string xbmc;
        public string XBMC
        {
            get { return xbmc; }
            set { xbmc = value; }
        }
        //后背图片
        public string hbpic;
        public string HBPIC
        {
            get { return hbpic; }
            set { hbpic = value; }
        }
        //后背图片id
        public int? hbid;
        public int? HBID
        {
            get { return hbid; }
            set { hbid = value; }
        }
        //后背编号
        public string hbbh;
        public string HBBH
        {
            get { return hbbh; }
            set { hbbh = value; }
        }
        //后背名称
        public string hbmc;
        public string HBMC
        {
            get { return hbmc; }
            set { hbmc = value; }
        }
        //口袋图片
        public string kdpic;
        public string KDPIC
        {
            get { return kdpic; }
            set { kdpic = value; }
        }
        //口袋图片id
        public int? kdid;
        public int? KDID
        {
            get { return kdid; }
            set { kdid = value; }
        }
        //口袋编号
        public string kdbh;
        public string KDBH
        {
            get { return kdbh; }
            set { kdbh = value; }
        }
        //口袋名称
        public string kdmc;
        public string KDMC
        {
            get { return kdmc; }
            set { kdmc = value; }
        }

        //领插片图片
        public string lcppic;
        public string LCPPIC
        {
            get { return lcppic; }
            set { lcppic = value; }
        }
        //领插片图片id
        public int? lcpid;
        public int? LCPID
        {
            get { return lcpid; }
            set { lcpid = value; }
        }
        //领插片编号
        public string lcpbh;
        public string LCPBH
        {
            get { return lcpbh; }
            set { lcpbh = value; }
        }
        //领插片名称
        public string lcpmc;
        public string LCPMC
        {
            get { return lcpmc; }
            set { lcpmc = value; }
        }


        //绣花部位图片
        public string xhbwpic;
        public string XHBWPIC
        {
            get { return xhbwpic; }
            set { xhbwpic = value; }
        }
        //绣花部位图片id
        public int? xhbwid;
        public int? XHBWID
        {
            get { return xhbwid; }
            set { xhbwid = value; }
        }
        //绣花部位编号
        public string xhbwbh;
        public string XHBWBH
        {
            get { return xhbwbh; }
            set { xhbwbh = value; }
        }
        //绣花部位名称
        public string xhbwmc;
        public string XHBWMC
        {
            get { return xhbwmc; }
            set { xhbwmc = value; }
        }
        //绣花字体图片
        public string xhztpic;
        public string XHZTPIC
        {
            get { return xhztpic; }
            set { xhztpic = value; }
        }
        //绣花字体图片id
        public int? xhztid;
        public int? XHZTID
        {
            get { return xhztid; }
            set { xhztid = value; }
        }
        //绣花字体编号
        public string xhztbh;
        public string XHZTBH
        {
            get { return xhztbh; }
            set { xhztbh = value; }
        }
        //绣花字体名称
        public string xhztmc;
        public string XHZTMC
        {
            get { return xhztmc; }
            set { xhztmc = value; }
        }
        //绣花颜色图片
        public string xhyspic;
        public string XHYSPIC
        {
            get { return xhyspic; }
            set { xhyspic = value; }
        }
        //绣花颜色图片id
        public int? xhysid;
        public int? XHYSID
        {
            get { return xhysid; }
            set { xhysid = value; }
        }
        //绣花颜色编号
        public string xhysbh;
        public string XHYSBH
        {
            get { return xhysbh; }
            set { xhysbh = value; }
        }
        //绣花颜色名称
        public string xhysmc;
        public string XHYSMC
        {
            get { return xhysmc; }
            set { xhysmc = value; }
        }


        //绣花备注
        public string txt_xh_remark;
        public string TXT_XH_REMARK
        {
            get { return txt_xh_remark; }
            set { txt_xh_remark = value; }
        }
        //工艺纽扣id
        public int? gy_nkid;
        public int? GY_NKID
        {
            get { return gy_nkid; }
            set { gy_nkid = value; }
        }

        //工艺门襟id
        public int? gy_mjid;
        public int? GY_MJID
        {
            get { return gy_mjid; }
            set { gy_mjid = value; }
        }
        //工艺领子id
        public int? gy_lzid;
        public int? GY_LZID
        {
            get { return gy_lzid; }
            set { gy_lzid = value; }
        }
        //工艺袖口id
        public int? gy_xkid;
        public int? GY_XKID
        {
            get { return gy_xkid; }
            set { gy_xkid = value; }
        }
        //备注
        public string txt_other_remark;
        public string TXT_OTHER_REMARK
        {
            get { return txt_other_remark; }
            set { txt_other_remark = value; }
        }
        //备注图片
        public string pic_urls;
        public string PIC_URLS
        {
            get { return pic_urls; }
            set { pic_urls = value; }
        }
    }
    //尺码
    public class cm
    {
        //部位id
        public string bwid;
        public string BWID
        {
            get { return bwid; }
            set { bwid = value; }
        }
        //规格修正值
        public decimal? ggxz;
        public decimal? GGXZ
        {
            get { return ggxz; }
            set { ggxz = value; }
        }
        //值
        public decimal? cmvalue;
        public decimal? CMVALUE
        {
            get { return cmvalue; }
            set { cmvalue = value; }
        }
    }
    //特体尺码
    public class ttcm
    {
        //特体id
        public string id;
        public string ID
        {
            get { return id; }
            set { id = value; }
        }

        //值
        public string ttcmvalue;
        public string TTCMVALUE
        {
            get { return ttcmvalue; }
            set { ttcmvalue = value; }
        }
    }
    public bool IsReusable {
        get {
            return false;
        }
    }

}